package cn.com.cifi.mars.mapper.mars;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import cn.com.cifi.mars.bean.dto.ApprovedDetailDto;
import cn.com.cifi.mars.bean.dto.OrgTreeDto;
import cn.com.cifi.mars.bean.dto.VersionTypeCountDto;
import cn.com.cifi.mars.entity.ApprovalBill;
import cn.com.cifi.mars.entity.PriceValueOrg;
import cn.com.cifi.mars.entity.PriceVersion;
import cn.com.cifi.mars.entity.common.ProjectByStages;

/**
 * 查询需要审批的项目信息（需要审批的分期以及版本）
 */
public interface ApprovedProjectMapper extends BaseMapper<PriceVersion> {
    List<PriceVersion> selectApprovedProject(@Param("projectId")String projectId);

    //根据projectId查询项目下所有分期的所有版本的个数
    List<VersionTypeCountDto> selectVersionTypeCount(@Param("projectId")String projectId);

    //根据projectId查询项目下所有审批通过的分期
    List<ProjectByStages> selectApprovedStageCount(@Param("projectId")String projectId, @Param("typeId") String typeId);

    //根据projectId查询需要展示的货值的id
    List<PriceVersion> selectVersionId(@Param("projectId")String projectId,@Param("versionType")String versionType,@Param("isAssessment")Integer isAssessment);

    //查询项目下是否有审批通过的stage
    int selectVersionType(@Param("projectId")String projectId,@Param("versionType")String versionType,
                          @Param("stageId")String stageId,@Param("isAssessment")Integer isAssessment);

    //查询项目下的分期
    List<String> getProjectfIds(@Param("projectId")String projectId);

    //明源已定价的取已定价的版本
    List<Map<String, Object>> selectBeforeAdjustFirst(@Param("projectfId")String projectfId,@Param("type")String type);

    //明源未定价，战规后取战规后的三个版本中最新的
    List<Map<String, Object>> selectBeforeAdjustSec(@Param("projectfId")String projectfId,@Param("type")String type);
    //明源未定价，战规后取战规后的三个版本中最新的
    List<Map<String, Object>> selectBeforeAdjustSec2(@Param("projectfId")String projectfId,@Param("type")String type);

    //明源未定价，战规前取投资版的最新版
    List<Map<String, Object>> getCastDecision(@Param("projectfId") String projectfId,@Param("type")String type);

    //审批校验
    List<PriceVersion> checkVersion(@Param("projectId")String projectId,@Param("state1")String state1,@Param("state2")String state2);
    //审批校验
    List<PriceVersion> checkApprovedVersionIsNull(@Param("projectId")String projectId);

    //插入编制中的版本
    List<PriceVersion> selectOrganizationVersion(@Param("projectId")String projectId, @Param("state")String state);

    //bill表插入前校验
    ApprovalBill selectBillCheck(@Param("projectId")String projectId, @Param("state1")String state1,@Param("state2")String state2,@Param("state3")String state3,@Param("type")String type);


    //差异详情表-查询组织树
    List<OrgTreeDto> selectCastDecisionAllOrgTree(@Param("versionId") String versionId,@Param("isDel") int isDel);
    List<OrgTreeDto> selectDynamicAllOrgTree(@Param("versionId") String versionId,@Param("isDel") int isDel);

    List<PriceValueOrg> selectPriceValueOrg(@Param("versionId") String versionId,@Param("isDel") int isDel);
    
    //查询项目是否存在 草稿 驳回发起 撤回发起的信息
    ApprovalBill insertBillCheckV2(@Param("projectId")String projectId, @Param("state")List<String> state,
    		@Param("businessType")String businessType);

	List<ApprovedDetailDto> selectApprovedDetailDto(@Param("versionId")String versionId,@Param("id")String id, @Param("isDel")int isDel);

	List<PriceValueOrg> selectPriceValueOrgList(@Param("projectId")String projectId, @Param("type")String type, @Param("isDel")int isDel);

	List<PriceVersion> selectVersionByBillId(@Param("instanceId")String instanceId);

	List<String> selectStageList(@Param("projectId")String projectId,@Param("status") String status, @Param("isDel") int isDel);

	

}
